package single.proxy;

public interface NetWork {
    public void browse();
}
//被代理
class Server implements NetWork{
    @Override
    public void browse() {
        System.out.println("真实访问服务器");
    }
}
//代理类
class ProxyServer implements NetWork{

    private NetWork work;

    public ProxyServer(NetWork work) {
        this.work = work;
    }
    public void check(){
        System.out.println("访问服务器前的检查工作");
    }
    @Override
    public void browse() {
        check();
        work.browse();
    }
}

class ProxyTest{
    public static void main(String[] args) {
        ProxyServer proxyServer = new ProxyServer(new Server());
        proxyServer.browse();

    }
}
